package com.xbongbong.saas.enums.dictionary;

import com.xbongbong.i18n.util.I18nMessageUtil;
import lombok.Getter;

import java.util.Objects;

/**
 * @author: yingjf
 * @date: 2022/8/16 18:40
 * @description: 竞争对手规模
 */
@Getter
public enum  CompetitorScaleEnum {
//    微型、小型、中型、大型、特大型
    MICRO("1", "enum.competitorScale.name.micro", "micro"),
    SMALL("2", "enum.competitorScale.name.small", "small"),
    MEDIUM("3", "enum.competitorScale.name.medium", "medium"),
    LARGE("4", "enum.competitorScale.name.large", "large"),
    EXTRA_LARGE("5", "enum.competitorScale.name.extraLarge", "extraLarge"),
    ;
    private String code;
    private String name;
    private String attr;

    CompetitorScaleEnum(String code, String name, String attr) {
        this.code = code;
        this.name = name;
        this.attr = attr;
    }

    public static CompetitorScaleEnum getByCode(String code) {
        for (CompetitorScaleEnum cache : values()) {
            if (Objects.equals(code, cache.code)) {
                return cache;
            }
        }
        return null;
    }

    public String getName() {
        return I18nMessageUtil.getMessage(name);
    }

}
